package com.linkoog.devtools.toolwindow_manager;

import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.project.Project;
import com.linkoog.devtools.maven.version_show.persistent.MavenPluginSettings;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.SortedMap;
import java.util.TreeMap;

@State(name = "toolwindow-manager", storages = @Storage("toolwindow-manager.xml"))
public class ToolwindowManagerPluginSettings implements PersistentStateComponent<ToolwindowManagerPluginSettings> {

    public static ToolwindowManagerPluginSettings getInstance(@NotNull Project project) {
        return project.getService(ToolwindowManagerPluginSettings.class);
    }

    private SortedMap<String, AvailabilityPreference> toolWindowPreferences = new TreeMap<>();

    @Nullable
    @Override
    public ToolwindowManagerPluginSettings getState() {
        return this;
    }

    @Override
    public void loadState(@NotNull ToolwindowManagerPluginSettings state) {
        this.toolWindowPreferences = state.toolWindowPreferences;
    }

    public SortedMap<String, AvailabilityPreference> getToolWindowPreferences() {
        return toolWindowPreferences;
    }

    public void setToolWindowPreferences(SortedMap<String, AvailabilityPreference> toolWindowPreferences) {
        this.toolWindowPreferences = toolWindowPreferences;
    }
}
